package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 * @author Luka
 * @date 2021/05/31 09:09
 *
 * 字符流
 * 只读/写文本数据
 **/
public class OSWDemo {
    public static void main(String[] args) throws IOException {
        //向文件中写入文本数据
        FileOutputStream fos = new FileOutputStream("osw.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");

        osw.write("左边画条龙");
        osw.write("右边画彩虹");
        osw.write("画个der");


        System.out.println("写出完毕");
        /*
            OSW内部有一小部分缓冲区,写完要关闭这个流或调用flush才能确保数据写出
         */
        osw.flush();
        fos.close();

    }
}